# if(CMAKE_CL_64)
  # message( STATUS "CMAKE_CL_64: ${CMAKE_CL_64}")
# endif()

set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "" FORCE)
set(CMAKE_INSTALL_PREFIX "d:/opt/fftw3" CACHE STRING "" FORCE)
if (NOT DEFINED CMAKE_BUILD_TYPE)
  set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif ()

#project (fftw)

if (POLICY CMP0042)
  cmake_policy (SET CMP0042 NEW)
endif ()

if (POLICY CMP0054)
  cmake_policy (SET CMP0054 NEW)
endif ()

option (BUILD_SHARED_LIBS "Build shared libraries" ON)
option (BUILD_TESTS "Build tests" OFF)

#option (ENABLE_OPENMP "Use OpenMP for multithreading" ON)
#option (ENABLE_THREADS "Use pthread for multithreading" ON)
#option (WITH_COMBINED_THREADS "Merge thread library" ON)

#option (ENABLE_SSE "Compile with SSE instruction set support" ON)
#option (ENABLE_SSE2 "Compile with SSE2 instruction set support" ON)
option (ENABLE_AVX "Compile with AVX instruction set support" ON)
#option (ENABLE_AVX2 "Compile with AVX2 instruction set support" OFF)


if (ENABLE_PTHREADS)
  find_package (Threads)
endif ()
if (Threads_FOUND)
  if(CMAKE_USE_PTHREADS_INIT)
    set (USING_POSIX_THREADS 1)
  endif ()
  set (HAVE_THREADS TRUE)
endif ()

if (ENABLE_OPENMP)
  find_package (OpenMP)
endif ()
if (OPENMP_FOUND)
  set (HAVE_OPENMP TRUE)
endif ()

if (BUILD_SHARED_LIBS)
  add_definitions (-DFFTW_DLL)
endif ()

if (OPENMP_FOUND)
 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OpenMP_C_FLAGS}")
endif ()

if (MSVC)
  #target_compile_definitions (${fftw3_lib} PRIVATE /bigobj)
  set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /GR /Gy /GT /GL /Qpar")
  set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
  set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
  set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
endif ()
